1 00:00:00,510 --> 00:00:01,820 Hello and welcome. 2 00:00:01,890 --> 00:00:12,570 In this lecture we are going to implement some trackin to track or store this cause we get when the 3 00:00:12,570 --> 00:00:13,860 brick is it. 4 00:00:13,970 --> 00:00:19,560 So go and try and implement some scoring here so that each time the ball hits the brake and the break 5 00:00:19,600 --> 00:00:23,950 disappear you get the mark or point for that. 6 00:00:23,970 --> 00:00:30,780 So the track record that we are also going to implement win the game. 7 00:00:30,780 --> 00:00:38,480 So when all the bricks have been hit and none is left on the compass that means you have won the game. 8 00:00:38,640 --> 00:00:45,230 So we're going to how are we going to create an alert now come up when all the breaks have been hit. 9 00:00:45,360 --> 00:00:48,540 To see Congress leisha's you have won the game. 10 00:00:48,690 --> 00:00:58,560 So when I implement that in this election we are going to create a variable that we can use to record 11 00:00:58,800 --> 00:01:01,060 this cause that you get. 12 00:01:01,500 --> 00:01:12,180 So we begin by typing in the world far and we'll call the variable score to make it simple and give 13 00:01:12,180 --> 00:01:21,880 it a value of zero to start with K and or saved that. 14 00:01:22,170 --> 00:01:32,250 Next we are going to create a function that we can use to create the score so we can actually draw the 15 00:01:32,250 --> 00:01:34,960 score is going to be a tax. 16 00:01:34,990 --> 00:01:36,840 But the way you do. 17 00:01:36,960 --> 00:01:43,790 You create a tax the same as where you create a ship. 18 00:01:43,830 --> 00:01:45,850 So let's do that. 19 00:01:46,080 --> 00:01:49,800 Okay I'm going to implement that just underneath me. 20 00:01:49,860 --> 00:01:58,390 Draw bricks function just on the maths here we've create a function. 21 00:01:59,010 --> 00:01:59,770 Okay. 22 00:01:59,870 --> 00:02:01,590 You start with the word function 23 00:02:04,980 --> 00:02:07,740 followed by the name of one accord a function. 24 00:02:07,940 --> 00:02:09,210 I'll call it a draw 25 00:02:13,210 --> 00:02:15,360 draw score. 26 00:02:19,640 --> 00:02:22,310 Okay who made that look. 27 00:02:25,740 --> 00:02:27,390 To save a bit of time. 28 00:02:27,400 --> 00:02:30,670 I've completed the code here. 29 00:02:30,840 --> 00:02:32,700 Let me just run through it with you. 30 00:02:32,700 --> 00:02:36,740 So we begin with the word function to create a function. 31 00:02:36,870 --> 00:02:42,650 The name of the function is drawn score and in between the curly braces. 32 00:02:42,750 --> 00:02:50,790 There are some parameters so the way you create you create a text on mccumber so everything on a canvas 33 00:02:50,850 --> 00:02:53,330 is treated more or less like graphics. 34 00:02:53,460 --> 00:02:58,810 So you create a text the same way you would create a shape. 35 00:02:58,950 --> 00:03:04,590 So you begin with the contents font method and you give it value. 36 00:03:04,600 --> 00:03:10,910 The value here this 18 pixels is the size of the text on the font. 37 00:03:10,920 --> 00:03:15,750 This this this this area here is the font family. 38 00:03:15,810 --> 00:03:21,040 Most computers should have that font so you can always specify whatever font you want. 39 00:03:21,040 --> 00:03:26,570 It is good to specify a font that most computers will have. 40 00:03:26,780 --> 00:03:28,470 So that's the font here. 41 00:03:28,740 --> 00:03:38,220 The context of field style is called or you would use to feel the call or you give the actual text that 42 00:03:38,220 --> 00:03:39,990 will display the score. 43 00:03:40,170 --> 00:03:46,680 So the context of field text method and artfully does the colouring of the text. 44 00:03:46,770 --> 00:03:56,010 So in between these barren pieces here this core here is this call Eataly relates to the outroar score 45 00:03:56,490 --> 00:04:00,890 that will be displayed for example if your points are 30. 46 00:04:01,040 --> 00:04:04,410 This is way to be this plate plots. 47 00:04:04,460 --> 00:04:13,000 What this plus is saying is that is telling you where it will pull xishun the score on the compass and 48 00:04:13,020 --> 00:04:14,690 it has to appear those here. 49 00:04:14,700 --> 00:04:27,540 So if say the position on the x axis on the y axis so it's pixels from the X and 20 pixels from the 50 00:04:27,540 --> 00:04:28,830 y axis. 51 00:04:28,830 --> 00:04:30,270 So that's the position. 52 00:04:30,290 --> 00:04:42,000 It'll place the score on the canvas to implement the score so that each time a brick is hit you get 53 00:04:42,090 --> 00:04:44,090 a point or score. 54 00:04:44,130 --> 00:04:55,380 We need to amend or add a line of code to the quad lead coalition detection function so that each time 55 00:04:55,500 --> 00:05:02,760 a brick is hit the function will increase the point so you get a point each time it brick is hit. 56 00:05:02,970 --> 00:05:05,440 So we then implement that. 57 00:05:05,550 --> 00:05:10,360 So let's look at the coalition detection function. 58 00:05:10,470 --> 00:05:17,000 That's where we can implement that sule solution detection. 59 00:05:17,040 --> 00:05:21,460 Right so this is the quick leash on detection function here. 60 00:05:21,480 --> 00:05:26,170 This is where I will implement that right. 61 00:05:26,250 --> 00:05:28,710 Just underneath here is where we're going to. 62 00:05:28,770 --> 00:05:30,810 That's all we going to add. 63 00:05:30,810 --> 00:05:36,910 The variable score reports we're going to type in score. 64 00:05:41,150 --> 00:05:48,430 This blast blows means increment So every time the break is hit it'll increase. 65 00:05:48,430 --> 00:05:52,440 That if you get the point added on to your score. 66 00:05:52,460 --> 00:05:54,350 That's what this means. 67 00:05:54,800 --> 00:05:56,510 So let's say that. 68 00:05:59,470 --> 00:06:03,600 Next we need to insert. 69 00:06:04,520 --> 00:06:12,210 And each state meant so that when all the breaks have been hit you get an alert message to tell you 70 00:06:12,210 --> 00:06:13,830 you have won the game. 71 00:06:13,900 --> 00:06:23,020 So we're going to implement in this state it will do that just on this score here on this score count. 72 00:06:23,030 --> 00:06:27,200 That's where we'll implement school and begin with if. 73 00:06:33,390 --> 00:06:33,980 All right. 74 00:06:33,990 --> 00:06:38,130 I have completed the code just to save a bit of time. 75 00:06:38,160 --> 00:06:41,420 So this is the state that implemented here. 76 00:06:41,580 --> 00:06:50,370 So what I'm saying is that if the score is equal to Debree cruel count times the brick column count 77 00:06:51,480 --> 00:06:53,400 is -- alert. 78 00:06:53,400 --> 00:06:56,640 Congratulations you have won. 79 00:06:56,670 --> 00:07:03,750 What that means is that if all the breaks have been cleared from the screen and not let you get this 80 00:07:03,750 --> 00:07:06,970 message say congratulations you have won. 81 00:07:07,280 --> 00:07:13,070 And what will commend the look is shown me is it that he reloads the game for his new session. 82 00:07:13,440 --> 00:07:17,970 So I saved that are right. 83 00:07:17,970 --> 00:07:23,490 The final thing we need to do is call how we call the draw. 84 00:07:23,490 --> 00:07:33,270 Score function so good to wear on our function has been called from our love functions calls from the 85 00:07:33,270 --> 00:07:35,470 draw function. 86 00:07:36,300 --> 00:07:37,760 Okay so here. 87 00:07:37,770 --> 00:07:48,690 This is where we're going to add medrol scores who added them all. 88 00:07:49,700 --> 00:07:50,250 King 89 00:07:54,700 --> 00:07:57,370 saw was a powder has been called. 90 00:07:57,570 --> 00:07:59,180 Then the draws go from. 91 00:07:59,220 --> 00:08:02,410 It's called before the leash detection. 92 00:08:02,640 --> 00:08:05,810 So save that and then we can test it. 93 00:08:06,630 --> 00:08:09,310 Okay let's test it and see. 94 00:08:09,690 --> 00:08:13,000 So as you can see the aim is there. 95 00:08:13,020 --> 00:08:15,290 So you got a score of two at the moment. 96 00:08:15,510 --> 00:08:18,590 So let's see if we can add one more. 97 00:08:18,960 --> 00:08:21,110 I missed that one. 98 00:08:22,320 --> 00:08:23,340 Let's try one more 99 00:08:27,640 --> 00:08:28,530 see Liz. 100 00:08:28,650 --> 00:08:30,200 Let's call off two. 101 00:08:30,360 --> 00:08:32,010 So that's how your. 102 00:08:32,100 --> 00:08:33,970 This is where your call would be recorded. 103 00:08:33,990 --> 00:08:40,770 Each time you hear the break this call comes here would be updated was all the breaks have been cleared 104 00:08:40,770 --> 00:08:41,940 from the compass. 105 00:08:42,120 --> 00:08:44,470 You get an alert saying you have won the game. 106 00:08:44,550 --> 00:08:48,640 So that's it for this lecture. 107 00:08:48,750 --> 00:08:59,430 So we have implemented a scoring for the game and som quickly shown detection with the in our previous 108 00:08:59,470 --> 00:09:00,080 lecture. 109 00:09:00,210 --> 00:09:03,440 So the game is almost complete. 110 00:09:03,440 --> 00:09:09,750 While we're on what we need to do next is implement some mouse control at the moment. 111 00:09:09,780 --> 00:09:17,730 I can't use my mouse to move the paddle so I have to be using the keyboard keys on the keyboard the 112 00:09:17,730 --> 00:09:23,310 errors back arrows to be moving the pad also is a bit cumbersome. 113 00:09:23,310 --> 00:09:26,240 Some will implement some mouse control in the next lecture. 114 00:09:26,250 --> 00:09:32,040 That way I can use the mouse movement will respond to the paddle so as more my mounds of paths will 115 00:09:32,040 --> 00:09:33,260 move with me. 116 00:09:33,510 --> 00:09:40,030 With the mouse movement so make it a lot easier to control the ball the ball with the paddle. 117 00:09:40,250 --> 00:09:42,430 So see you in the next lecture. 118 00:09:42,540 --> 00:09:44,040 Thank you both hon.